﻿// <copyright file="OptionsForm.cs" company="QUT">
//     Copyright (c) QUT. All rights reserved.
// </copyright>

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LRT.GUI
{
    /// <summary>
    /// Options Form for Localisation Resource Toolkit
    /// </summary>
    public partial class OptionsForm : Form
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="OptionsForm"/> class.
        /// </summary>
        public OptionsForm()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Handles the Load event of the OptionsForm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OptionsForm_Load(object sender, EventArgs e)
        {
            var settings = Properties.Settings.Default;
            this.UseTranslationMemoryCheckBox.Checked = settings.UseTranslationMemory;
            this.TranslationMemoryCellColourSampleTextBox.BackColor = settings.TranslationMemoryCellColour;
            this.UseGoogleTranslateCheckBox.Checked = settings.UseTranslationMemory;
            this.GoogleTranslateCellColourSampleTextBox.BackColor = settings.GoogleTranslateCellColour;
        }

        /// <summary>
        /// Handles the Click event of the ChangeTranslationMemoryCellColour control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ChangeTranslationMemoryCellColour_Click(object sender, EventArgs e)
        {
            if (this.OptionsColorDialog.ShowDialog() == DialogResult.OK)
            {
                this.TranslationMemoryCellColourSampleTextBox.BackColor = this.OptionsColorDialog.Color;
            }
        }

        /// <summary>
        /// Handles the Click event of the ChangeGoogleTranslateCellColourButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ChangeGoogleTranslateCellColourButton_Click(object sender, EventArgs e)
        {
            if (this.OptionsColorDialog.ShowDialog() == DialogResult.OK)
            {
                this.GoogleTranslateCellColourSampleTextBox.BackColor = this.OptionsColorDialog.Color;
            }
        }

        /// <summary>
        /// Handles the Click event of the OptionsOKButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OptionsOKButton_Click(object sender, EventArgs e)
        {
            var settings = Properties.Settings.Default;
            settings.UseTranslationMemory = this.UseTranslationMemoryCheckBox.Checked;
            settings.TranslationMemoryCellColour = this.TranslationMemoryCellColourSampleTextBox.BackColor;
            settings.UseGoogleTranslate = this.UseGoogleTranslateCheckBox.Checked;
            settings.GoogleTranslateCellColour = this.GoogleTranslateCellColourSampleTextBox.BackColor;
            settings.Save();
            this.Close();
        }

        /// <summary>
        /// Handles the Click event of the OptionsCancelButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OptionsCancelButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
